var p = $("#300_ad_parent");
var position = p.position();
var default_ad_position = position.top;
var default_ad_position_left = position.left;

var p1 = $("#300_ad_parent1");
var position1 = p1.position();
var default_ad1_position = position1.top;
//$("#test_div1").html( "left: " + position.left + ", top: " + position.top );
//300_ad_parent
//$("#300_ad_parent").offset({ top: 1100, left: 749})




var p = $("#test_div");
var position = p.position();

$(window).scroll(function () { 
var p2 = $("#footer");
var position2 = p2.position();
var default_ad2_position = position2.top;
default_ad2_position=default_ad2_position-650;
//alert(default_ad2_position);
    //You've scrolled this much:
      // $('#test_div1').text("You've scrolled " + $(window).scrollTop() + " pixels");
	   if (($(window).scrollTop() > position.top + 20) && $(window).scrollTop() < default_ad2_position)
	   {
	   		$("#300_ad_parent").offset({ top: $(window).scrollTop() + 10, left: default_ad_position_left});
			$("#300_ad_parent1").offset({ top: $(window).scrollTop() + 310, left: default_ad_position_left});
	   }
	   else
	   //if ($(window).scrollTop() < position.top + 20)
	   {
	   		$("#300_ad_parent").offset({ top: default_ad_position, left: default_ad_position_left})
			$("#300_ad_parent1").offset({ top: default_ad1_position, left: default_ad_position_left})
	   }
});
